<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>注册</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<div style="width:500px" align="center">
		<div>
			<span>注册邮箱:</span><input id="email" type="text" name="email"
				onblur="fun()" /><span id="div1">*</span>
		</div>
		<div>
			<span>用户名:</span> <input type="text" name="name" /> <span id="div2">*</span>
		</div>
		<div>
			<span>密码:</span><input type="password" name="pwd" /><span id="div3">*</span>
		</div>
		<div>
			<span>确认密码:</span><input type="password" name="repwd" /><span
				id="div4">*</span>
		</div>
		<input type="button" value="注册" onclick="chang()" />
	</div>
</body>
<script src="js/jquery-1.8.3.js" type="text/javascript"></script>
<script type="text/javascript">
	function fun() {
		var email = $("#email").val();
		if(email==null||email==""){
		alert("邮箱不能为空");
		   return ;
		}
		alert(email);
		$.ajax({
			type : "post",
			url : "UserNameServlet",
			data : "email=" + email,
			"dataType" : "text",
			"success" : function(data) {
			
				if (data == "true") {
					$("#div1").html("该用户名已存在!");
				} else {
					$("#div1").html("该用户名可以使用");
				}
			},
			"error" : function() {
				alert("请联系管理员" + email);
			}
		});
	}

	function chang() {
		$.ajax({
			type : "get",
			url : "InsertServlet",
			data : "result=" + result,
			"dataType" : "text",
			"success" : function(data) {
				if (data > 0) {
					alert("注册成功");
				} else {
					alert("注册失败");
				}
			}
		});
	}
</script>
</html>
